package com.yuwubao.hz_International.entities.repository

import com.yuwubao.hz_International.entities.GiftFans
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.JpaSpecificationExecutor
import org.springframework.data.jpa.repository.Query

interface GiftFansRepo : JpaRepository<GiftFans, Int>, JpaSpecificationExecutor<GiftFans> {
    @Query("select * from gift_fans where userId=?1 and phone = ?2", nativeQuery = true)
    fun findByPhone(id: Int, invitePhone: String?): GiftFans?

    @Query(nativeQuery = true, value = "SELECT sum(totalGift) from gift_fans where userId = ?1")
    fun findByUserId(userId: Int): java.math.BigDecimal

    fun findByUserId(userId: Int, pageable: Pageable): Page<GiftFans>
}